package org.example.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.example.domain.po.ErpUnit;
import org.example.service.ErpUnitService;
import org.example.mapper.ErpUnitMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 3400
* @description 针对表【erp_unit(多单位表)】的数据库操作Service实现
* @createDate 2024-10-30 09:40:16
*/
@Service
public class ErpUnitServiceImpl extends ServiceImpl<ErpUnitMapper, ErpUnit>
    implements ErpUnitService{
    //分页查询
    public Page<ErpUnit> findByPage(Page<ErpUnit> page , @Param("attributeName") String attributeName,  @Param("tenantId") Long tenantId){
        return baseMapper.findByPage(page,attributeName,tenantId);
    }
    public List<ErpUnit> selectByExample(Long tenantId){
        return this.baseMapper.selectByExample(tenantId);
    }
    public List<ErpUnit> select(Integer id, Long tenantId){
        return this.baseMapper.select(id,tenantId);
    }

    @Override
    public boolean modifyTheState(List<Integer> ids, Integer enabled) {
        boolean status = (enabled == 1); // Convert 1 to true, 0 to false
        return lambdaUpdate().set(ErpUnit::getEnabled, status)
                .in(ErpUnit::getId, ids)
                .update();
    }


}




